<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page isELIgnored="false"%>
<%@ include file="../common/taglibs.jsp"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <title>商户数量统计</title>
    <link rel="icon" href="favicon.ico" type="image/x-icon"/>
    <!-- 当前页面样式 -->
    <link rel="stylesheet" href="<s:url value="/css/common.css"/>"/>
    <!-- 当前页面样式 END -->
    <script type="text/javascript" src="<c:url value="/js/jquery-1.3.2.js" />"></script>
	<script type="text/javascript" src="<c:url value="/js/common.js" />"></script>
	<script type="text/javascript" src="<c:url value="/js/My97DatePicker/WdatePicker.js"/>"></script>
	<script type='text/javascript' src='<s:url value="/js/pageAjax.js"/>'></script>
	<script type='text/javascript' src='<s:url value="/dwr/engine.js"/>'></script>
	<script type='text/javascript' src='<s:url value="/dwr/interface/MccQuery.js"/>'></script>
	<script type='text/javascript' src='<s:url value="/js/querySon.js"/>'></script>
	<script type="text/javascript">
$(document).ready(function(){
	$('#sub').click(function(){
		if(!checkDate()){
	           return false;
	         }
		 $("#sub").attr("disabled", true);
			$("#queryCommNumber").attr("action","<%=basePath%>/commNumberStat/queryCommNumberStat.ct");
			$("#queryCommNumber").submit();
		});
	$('#szPower').click(function(){
		if(!checkDate()){
	           return false;
	         }
		 $("#szPower").attr("disabled", true);
		$("#queryCommNumber").attr("action","<%=basePath%>/commNumberStat/queryCommNumberDetail.ct");
		$("#queryCommNumber").submit();
	});
}); 
	
	function  checkDate(){
		var endTime = $("#maxDate").val();
		var beginTime = $("#minDate").val();
		if(!endTime || !beginTime){
			alert("请选择时间范围!");
			return false;
		} 
		var date1=str2date(beginTime);
		var date2=str2date(endTime);

	    var dates = (date2 - date1)/(1000*60*60*24); 
	    if(dates < 0){
		    alert("选择时间错误！");
			return false;
	    }
	    if(dates > 29){
		    alert("选择时间相隔不能超过30天！");
			return false;
	    }
		return true;
	}
	
	function   str2date(str){
		var d=null;   
		var reg=/^(\d{4})(\d{2})(\d{2})$/  ;
			if(arr=str.match(reg))d=new   Date(Number(arr[1]),Number(arr[2])-1,Number(arr[3])) ; 
		return   d;   
	}

</script>
</head>
<body>
<s:form id="queryCommNumber" action="/merTerm/queryCommNumberStat.ct" method="post" theme="simple">
<s:hidden id="userId" value="%{#session.session_merchant.id}"/>
<table class="tb">
    <tbody>
        <tr class="tb-line">
            <td class="tb-td" colspan="4"><div class="tb-h2">POS收单运营管理平台</div></td>
        </tr>

        <tr class="tb-line">
            <td class="tb-td" colspan="4"><div class="tb-h3">商户数量统计</div></td>
        </tr>
 
       <tr class="tb-line">
            <td align="right" class="tb-td">
                <div class="tb-h4">分公司：</div>
            </td>
            <td class="tb-td">
                <label class="tb-input-normal">
                	<s:textfield id="name" name="searchCondition.companyName" />
               	</label>
            </td>
            <td align="right" class="tb-td">日期：</td>
			<td class="tb-td">
	                <label class="tb-input-mini">
	                	<s:textfield id="minDate" name="searchCondition.minDate" onFocus="WdatePicker({dateFmt:'yyyyMMdd',readOnly:true,wdate:true,errDealMode:0});"
							theme="simple" cssClass="queryWidth" /> 
					</label> -
					<label class="tb-input-mini">
						<s:textfield id="maxDate" name="searchCondition.maxDate" onFocus="WdatePicker({dateFmt:'yyyyMMdd',readOnly:true,wdate:true,errDealMode:0});"
							theme="simple" cssClass="queryWidth" />
					</label>
					<code class="asterisk">*</code>
				</td>
        </tr>
        
	        
		
        <tr class="tb-line">
            <td class="tb-td line-submit" align="right" colspan="4">
                <label class="tb-input-submit">
                   <input type="button" value="查询" id="sub"/>
                </label>
                <label class="tb-input-submit">
                    <input type="reset" value="取消"/>
                </label> 
                <label class="tb-input-submit">
                	<s:if  test="#request.searchRsList != null && #request.searchRsList.size>0">
						<input id="szPower" type="button" value="导出" />
					</s:if>
					<s:else>
					 	<input id="szPower" disabled="disabled" value="导出" type="button" />
					</s:else>
                </label> 
            </td>
        </tr>
		<s:if  test="#request.cclist != null && #request.cclist.size>0">
					<tr class="tb-line">
				<td class="tb-td paging"  align="left" colspan="4"> 
					 	<page:pageCount max_pages="11" totalPage="${requestScope.totalPage}"
						currentPage="${requestScope.currentPage}"
						action="${rootPath}/commNumberStat/queryCommNumberStat.ct?currentPage=" />
				</td>
			</tr>
	</s:if>
    </tbody>
</table>
</s:form>
<div class="big-tb">
    <table class="tb" style="width: 100%;">
        <thead>
            <tr class="tb-line">
                <th class="tb-th" colspan="24">商户数量统计结果</th>
            </tr>
            
            <tr class="tb-line bg-gray">
            	<th class="tb-th">日期</th>
				<th class="tb-th">分公司</th>
				<th class="tb-th">总商户数量</th>
				<!-- <th class="tb-th">当日商户数量</th> -->
				<th class="tb-th">累计进件数量</th>
				<th class="tb-th">所属区域</th>
            </tr>
        </thead>
        <tbody>
			<s:iterator value="#request.cclist" status="stat" id="sh">
				<tr class="tb-line" >
					<td class="tb-td"><s:property value="#sh.minDate"/></td>
			        <td class="tb-td"><s:property value="#sh.companyName"/></td>
			        <td class="tb-td"><s:property value="#sh.commNumber"/></td>
			        <!-- <td class="tb-td"><s:property value="#sh.sunCommNumber"/></td> -->
					<td class="tb-td"><s:property value="#sh.sunPieceNumber"/></td>
					<td class="tb-td"><s:property value="#sh.areaCode"/></td>					
			      </tr>
			</s:iterator>		
        </tbody>
    </table>
   
</div>
 <s:if test="#request.msg !=null">
		<script language="javascript">
			alert("${request.msg}");
		</script>
	</s:if>
</body>
</html>